# -*- coding: utf-8 -*-
import logging

from django.http import JsonResponse
from rest_framework import status
from rest_framework.decorators import action
from rest_framework.response import Response
from rest_framework.viewsets import GenericViewSet

from django_service.messages import default_response, message_response

logger = logging.getLogger(__name__)


class BlockingView(GenericViewSet):
    """
    阻塞视图
    """

    @action(methods=['post'], detail=False)
    def calc(self, *args, **kwargs):
        logger.info(self.request.data)
        return JsonResponse(message_response(self.request.data))

    @action(methods=['get'], detail=False)
    def query(self, *args, **kwargs):
        logger.info(self.request.query_params)
        return JsonResponse(message_response(self.request.data))

    @action(methods=['post'], detail=False)
    def check(self, *args, **kwargs):
        logger.info(self.request.data)
        return JsonResponse(message_response(self.request.data))
